package entity

import (
	"encoding/json"
	"github.com/go-playground/validator/v10"
)

type PriceInfosType struct {
	BackProductCode string `json:"back_product_code" validate:"required"`
	PriceRate       string `json:"price_rate" validate:"required"`
}

type SettleInMerchantLicenseType struct {
	Name  string `json:"name" validate:"required"`
	Phone string `json:"phone" validate:"required"`
}

type AlipayCommerceMerchantcardOpenCreateEntity struct {
	MerchantName string            `json:"merchant_name" validate:"required"`
	Pid          string            `json:"pid" validate:"required"`
	CardTypes    []string          `json:"card_types" validate:"required"`
	NeedAuth     bool              `json:"need_auth" validate:"required"`
	PriceInfos   []*PriceInfosType `json:"price_infos" validate:"required"`
	//PriceInfoss             []*PriceInfosType          `json:"price_infos" validate:"required"`
	SettleInMerchantLicense *SettleInMerchantLicenseType `json:"settle_in_merchant_license" validate:"required"`
}

func (a *AlipayCommerceMerchantcardOpenCreateEntity) GetApiMethodName() string {
	return "alipay.commerce.merchantcard.open.create"
}

func (a *AlipayCommerceMerchantcardOpenCreateEntity) GetBizContent() string {
	err := validator.New().Struct(a)
	if err != nil {
		panic(err)
	}
	data, err := json.Marshal(a)
	if err != nil {
		panic(err)
	}
	return string(data)
}
